package com.etc.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.etc.service.impl.AnnouncementServiceImpl;
import com.etc.entity.Announcement;

import com.etc.service1.AnnouncementService;


/**
 * Servlet implementation class ModifyAnnouncementServlet
 */
@WebServlet("/ModifyAnnouncementServlet")
public class ModifyAnnouncementServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ModifyAnnouncementServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
     	String uid=request.getParameter("uid");
		String username=request.getParameter("username");
		String title=request.getParameter("title");
		String content=request.getParameter("content");
		AnnouncementService an=new AnnouncementServiceImpl();
		if(username!=null&&username!="") {
			Announcement announcement=new Announcement(Integer.valueOf(uid),username,title,content);
			Boolean result=an.modifyAnnouncement(announcement);
			response.sendRedirect("ListAnnouncementServlet");
	}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
